/*********************************************************************
* File:: NavigationSampleAgent.h
* \brief The navigation API sample.
*********************************************************************/
#pragma once
#pragma warning (disable: 4482) // Ignore non-standard extension warnings

#include "../Agent.h"
using namespace agents;

namespace agents{ namespace samples{
	/**
	* \class NavigationSampleAgent
	* \brief The navigation API sample.
	*
	* The agents respond to the following chat messages:
	* - \c position or \c p: Responds with the current position
	* - \c angles or \c a: Responds with the current moving angles
	* - \c moveF or \c f: Makes the agent move forward until \c stop is invoked
	* - \c moveB or \c b: Makes the agent move backwards until \c stop is invoked
	* - \c moveL or \c l: Makes the agent move to the left until \c stop is invoked
	* - \c moveR or \c r: Makes the agent move to the right until \c stop is invoked
	* - \c turnL or \c tL: Makes the agent rotate to the left until \c stop is invoked
	* - \c turnR or \c tR: Makes the agent rotate to the right until \c stop is invoked
	* - \c jump or \c j: Makes the agent jump
	* - \c duck or \c d: Makes the agent duck for 5 seconds
	* - \c moveToHere or \c mH: Makes the agent move to the player position (uses the agents::interfaces::IFreeNavigation API)
	* - \c moveToGoal or \c mG: Makes the agent move to an arbitrary goal position (uses the agents::interfaces::IWaypointNavigation API)
	* - \c moveToWaypoint (or \c m) <waypointIndex>: Makes the agent move to an arbitrary waypoint (uses the agents::interfaces::IWaypointNavigation API)
	* - \c stop or \c s: Makes the agent stop, abandoning its current destination
	* - \c hold or \c h: Makes the agent hold, resuming its path 5 seconds afterwards
	* - \c isStuck or \c sk: Reports whether the agent is stuck
	* - \c dH: Reports distance towards player
	*
	* \author Instituto Superior Tecnico de Lisboa, Portugal
	* \author Technical University of Lisbon, Portugal
	* 
	* \author Agentes Autonomos e Sistemas Multiagente
	* \author Autonomous Agents and Multiagent Systems
	* 
	* \version	1.0
	* \date		2006/2007
	**/
	class NavigationSampleAgent: public Agent
	{
	public:
		NavigationSampleAgent(edict_t *enity, int team, int model);
		~NavigationSampleAgent();

	private:
		void stop();
		void newRound();
		void think();
		void handleMessage(ICommunication::MessageRecord& record);

		enum Operations
		{
			moveForward = 0, 
			moveBackwards, 
			moveLeft, 
			moveRight,
			turnLeft, 
			turnRight, 
			max
		};

		typedef struct record_s
		{
			bool enabled;
			double timeout;
		} record_t;

		record_t records[Operations::max];

		bool _isDucking;
		float _duckTimeout;

		bool _isHolding;
		float _holdTimeout;
	};
}}